package com.mioto.ld.module.statistics;

import cn.hutool.core.date.DateUtil;
import com.mioto.ld.module.statistics.model.SearchConditionDTO;

import java.util.Date;


/**
 * @author mioto-qinxj
 * @date 2024/6/16
 * @desc 周销量统计
 */
public class WeekStatistics extends AbstractStatistics {
    public WeekStatistics() {
        index = 7;
    }

    @Override
    protected void calSearchDate(SearchConditionDTO searchDTO) {
        searchDTO.setEndTime(DateUtil.dateSecond());
        Date startDate = DateUtil.beginOfDay(DateUtil.offsetDay(searchDTO.getEndTime(),- index + 1));
        searchDTO.setStartTime(startDate);
        searchDTO.setSameCompareStartDate(DateUtil.offsetDay(startDate, -index));
        searchDTO.setSameCompareEndDate(DateUtil.offsetSecond(startDate,-1));
    }

}
